﻿using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using System.Data;
using BEGDC.Utility.NHibernate;
using Castle.Services.Transaction;
using System.Collections;
using System.Xml;
using Castle.Facilities.NHibernateIntegration;

namespace BEGDC.PreContract.BLL
{
	public partial class PreContractInfoComment: IPreContractInfoComment
	{
        public DataTable GetPreContractInfoCommentView(string filter)
        {
            using (ISession session = factory.OpenSession())
            {
                string strSql = "SELECT * FROM vw_PreContractInfoComment";
                if (filter != string.Empty)
                    strSql += " WHERE " + filter;

                DataTable dtSearch = DAO.ExecuteDataTable(session, strSql);

                return dtSearch;
            }
        }

        //Joan 2008-10-20 get the lasted commentid for a pre-contact
        public DataTable GetLatestCommentID(int precontractID)
        {

            using (ISession session = factory.OpenSession())
            {
                string strSql = "SELECT TOP 1 PreContractInfoCommentID FROM dbo.PreContractInfoComment WHERE PreContractID=" + precontractID.ToString() + " ORDER BY DateCreated DESC";
                DataTable dtSearch = DAO.ExecuteDataTable(session, strSql);

                return dtSearch;
            }      
        }
	}
}



